import com.jt.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testUserDemo {

    //测试单例 多例
    @Test
    public void testUser(){

        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
        context.getBean("user");
        context.getBean("user");
        context.getBean("user");

    }
    //测试声明周期运行
    @Test
    public void testLife(){

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
        //获取对象
        User user = (User) context.getBean("user");
        //3.用户调用方法
        user.say();
        //4.只要容器关闭，则对象销毁
        context.close();

    }

}
